#include "systemc.h"
#include <iostream>
#include <iomanip>
struct mac
{
    sc_uint<8> mac_addr[6];
    // Constructor:
    mac()
    {}

    mac(const mac &a)
    {
        this->mac_addr[0] = a.mac_addr[0];
        this->mac_addr[1] = a.mac_addr[1];
        this->mac_addr[2] = a.mac_addr[2];
        this->mac_addr[3] = a.mac_addr[3];
        this->mac_addr[4] = a.mac_addr[4];
        this->mac_addr[5] = a.mac_addr[5];
    }
    mac(int add0, int add1, int add2, int add3, int add4, int add5)
    {
        this->mac_addr[0] = add0;
        this->mac_addr[1] = add1;
        this->mac_addr[2] = add2;
        this->mac_addr[3] = add3;
        this->mac_addr[4] = add4;
        this->mac_addr[5] = add5;
    }
    inline mac &operator =(const mac &a)
    {
        this->mac_addr[0] = a.mac_addr[0];
        this->mac_addr[1] = a.mac_addr[1];
        this->mac_addr[2] = a.mac_addr[2];
        this->mac_addr[3] = a.mac_addr[3];
        this->mac_addr[4] = a.mac_addr[4];
        this->mac_addr[5] = a.mac_addr[5];
        return *this;
    }
    inline bool operator == (const mac &rhs) const
    {
        return (rhs.mac_addr[0] == mac_addr[0] && rhs.mac_addr[1] == mac_addr[1] && rhs.mac_addr[2] == mac_addr[2] && rhs.mac_addr[3] == mac_addr[3] && rhs.mac_addr[4] == mac_addr[4] && rhs.mac_addr[5] == mac_addr[5]);
    }

};

inline
ostream &
operator << (ostream &os, const mac &a)
{
    for(int i = 0; i < 5; i++)
    { os << std::setfill('0') << std::setw(2) << a.mac_addr[i] << ":" ; }

    os << std::setfill('0') << std::setw(2) << a.mac_addr[5];
    return os;
}

inline
void
#if defined(SC_API_VERSION_STRING)
sc_trace(sc_trace_file *tf, const mac &a, const std::string &name)
#else
sc_trace(sc_trace_file *tf, const mac &a, const sc_string &name)
#endif
{
    unsigned char i;

    for(i = 0; i < 6; i++)
    { sc_trace(tf, a.mac_addr[i], name); }

    for(i = 0; i < 6; i++)
    { sc_trace(tf, a.mac_addr[i], name); }
}


